package de.hu.wbi.histoner.train;

/**
Copyright 2011,2012 Philippe Thomas
This file is part of histoner.

HistoNer is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.

HistoNer  is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with HistoNer .  If not, see <http://www.gnu.org/licenses/>.
*/

/**
 * HistoNer learns pattern from raw natural language sentences. This class was used to generate such sentences, by reading all articles contained
 * in an lucene index. FIle is available on request.    
 * @author philippe
 *
 */
public class Sentences {

	static String index="/local/colonet/colonet/combined/lucene";
	static String outFile = "sentenes.txt.gz";
	public static void main(String[] args) {
		
//		MySQL mysql = new MySQL();
//		mysql.connect();
//		Connection con = mysql.getConn();
//		PreparedStatement ps = con.prepareStatement("SELECT begin, end FROM sentences WHERE pmid = ? ORDER BY begin ");
//		
//		IndexSearcher is = new	IndexSearcher( new SimpleFSDirectory(new File(index)),true);//Read Only
//		QueryParser qp = new QueryParser(Version.LUCENE_29, "FULLTEXT", new StandardAnalyzer( Version.LUCENE_29));
//		Query q = qp.parse("histon*");
//		TopDocs td= is.search(q, 10000000);
//		
//		System.out.println("Number of documents: " +td.totalHits);		
//		ScoreDoc[] sds= td.scoreDocs;
//		System.out.println(sds.length);
//		BufferedWriter bw =  new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(outFile)),"UTF-8")); 
//
//		for(int i=0; i< sds.length; i++){
//			ScoreDoc sd = sds[i];
//			Document document = is.doc(sd.doc);
//			
//			int pmid = Integer.parseInt(document.get("PMID"));
//			String fulltext = document.get("FULLTEXT");
//			ps.setInt(1, pmid);
//			ResultSet rs= ps.executeQuery();
//			bw.append(pmid +"\n");
//			while(rs.next()){
//				bw.append(fulltext.substring(rs.getInt("begin"), rs.getInt("end")) +"\n");
//			}
//		}
//		bw.close();
	}

}
